package com.app.view.component.dialogs.pkResultView 
{
	import com.app.model.data.UserData;
	import flash.utils.ByteArray;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class PkResultData 
	{
		public static const SEAT_COUNT:int = 7;
		
		private var _banker:Array = null;
		private var _playr:Array = null;
		
		public function PkResultData() 
		{
			
		}
		
		public function isHasBankerPaijiu():Boolean
		{
			if (_banker && _banker.length > 0) return true;
			
			return false;
		}
		
		public function setBanker(first:Array, second:Array, bankerData:UserData):void
		{
			_banker = [];
			_banker[0] = first;
			_banker[1] = second;
			
			_banker[2] = bankerData;
		}
		
		public function getBankerPaijiuFirstGroup():Array
		{
			return _banker[0];
		}
		
		public function getBankerPaijiuSecondGroup():Array
		{
			return _banker[1];
		}
		
		public function getBanker():UserData
		{
			return _banker[2] as UserData;
		}
		
		public function setPlayr(seatid:int, first:Array, second:Array, playrData:UserData, result:int, bankerMax:int, playrMax:int, pkType:int):void
		{
			if (!_playr) _playr = [];
			if (!_playr[seatid]) _playr[seatid] = [];
			
			_playr[seatid][0] = first;
			_playr[seatid][1] = second;
			
			_playr[seatid][2] = playrData;
			
			_playr[seatid][3] = result;
			_playr[seatid][4] = bankerMax;
			_playr[seatid][5] = playrMax;
			_playr[seatid][6] = pkType;		//1:接受 0:认输
		}
		
		public function getPlayrPaijiuFirstGroup(seatid:int):Array
		{
			if (!_playr || !_playr[seatid]) return null;
			
			return _playr[seatid][0];
		}
		
		public function getPlayrPaijiuSecondGroup(seatid:int):Array
		{
			if (!_playr || !_playr[seatid]) return null;
			
			return _playr[seatid][1];
		}
		
		public function getPlayr(seatid:int):UserData
		{
			if (!_playr || !_playr[seatid]) return null;
			
			return _playr[seatid][2] as UserData;
		}
		
		public function getPlayrResult(seatid:int):Array
		{
			if (!_playr || !_playr[seatid]) return null;
			
			return (_playr[seatid] as Array).slice(3);
		}
		
		public function rest():void
		{
			_banker = null;
			_playr = null;
		}
		
		/*
		function cloneObject(source:Object):PkResult 
		{
			var typeName:String = getQualifiedClassName(source); //获取全名
			trace("class = " + typeName);
			
			var packageName:String = typeName.split("::")[0]; //切出包名
			trace("class = " + packageName);
			var type:Class = getDefinitionByName(typeName) as Class; //获取Class
			trace(type);
			registerClassAlias(packageName, type); //注册Class
			
			var copier:ByteArray = new ByteArray();
			copier.writeObject(source);
			copier.position = 0;
			return copier.readObject();
		}
		*/
	}

}